from selenium import webdriver
from selenium.webdriver.common.by import By
import time

driver = webdriver.Chrome()
driver.get('https://www.baidu.com')
driver.maximize_window()

time.sleep(2)

# xpath 标签+属性
kw = driver.find_element(By.XPATH,'//input[@id="kw"]')
print(kw.get_attribute('outerHTML'))

wd = driver.find_element(By.XPATH,'//input[@name="wd"]')
print(wd.get_attribute('outerHTML'))

maxlength = driver.find_element(By.XPATH,'//input[@maxlength="255"]')
print(maxlength.get_attribute('outerHTML'))

inputs = driver.find_elements(By.XPATH, '//input')
for input in inputs:
    print(input.get_attribute('outerHTML'))

